package com.teaching.teachingsupport.controller.teachercontroller;

import com.teaching.teachingsupport.common.api.Result;
import com.teaching.teachingsupport.common.utils.SecurityUtils;
import com.teaching.teachingsupport.service.service2.teacherservice.TeachingClassService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/teacher/class")
@RequiredArgsConstructor
public class TeachingClassController {

    private final TeachingClassService teachingClassService;
    private final SecurityUtils securityUtils;

    /**
     * 获取教学班列表
     */
    @GetMapping("/getTeachingClasses")
    public Result<?> getTeachingClasses(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer size,
            @RequestParam(required = false) String grade,
            @RequestParam(required = false) String courseStatus,
            @RequestParam(required = false) String studentStatus,
            @RequestParam(required = false) String courseName) {
        return Result.success(teachingClassService.getTeachingClassesByUserId(
                securityUtils.getCurrentUserId(), 
                page, 
                size,
                grade,
                courseStatus,
                studentStatus,
                courseName));
    }

    /**
     * 获取教学班管理信息
     * 返回教学班信息、学生人数、是否毕业等状态
     */
    @GetMapping("/management")
    public Result<?> getTeachingClassManagement(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer size,
            @RequestParam(required = false) Integer courseId,
            @RequestParam(required = false) String grade) {
        return Result.success(teachingClassService.getTeachingClassManagement(
            securityUtils.getCurrentUserId(), 
            courseId,
            grade,
            page, 
            size
        ));
    }
} 